home *** CD-ROM | disk | FTP | other *** search
-
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
- /* */
- /* Prototype HP15C Calculator */
- /* James C. Ullrey */
- /* INRESCO */
- /* © 1990 */
- /* Version 13.97a */
- /* */
- /* WIZARD SEGMENT */
- /* */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
-
- /*****************************************************************/
- /* I N C L U D E S
- /*****************************************************************/
- #ifndef __C14__
- #include "PredatorPrey.h"
- #endif
-
- #include "windows.h"
- #include "calc_wizard.h"
- #include "Globals.h"
- #ifndef __C14D__
- #include "PredatorPreyData.h"
- #endif
- #ifndef __RED__
- #include "ResourceDefs.h"
- #endif
- #include "Miscellany.h"
- #include "Dispatcher.h"
- #include "MainWindow.h"
-
-
- #define dialogTop 75
- #define dialogLeft 85
-
- /********************************************************************/
- /* G L O B A L V A R I A B L E D E C L A R A T I O N S*/
- /********************************************************************/
-
-
- extern Boolean gLoadProgEnabled;
-
- short numOpenTypes;
- SFTypeList openPTypeList;
- SFTypeList openDTypeList;
- SFTypeList openBTypeList;
-
- extern void DoShowWindow(void);
-
- static void DoNew (void);
- static void DoOpen (void);
- static void DoSaveDataAs (void);
- static void DoSaveProgAs (void);
- static void DoSaveData (void);
- static void DoSaveProg (void);
-
- void wizard_seg() {} /* for reference in "UnloadSeg()" calls */
-
-
- /*----------*/
- void InitFileMD (void)
- {
- numOpenTypes = 1;
- openDTypeList [0] = lFileType;
- } /*InitFileM*/
-
- /*----------*/
- void InitFileMP (void)
- {
- numOpenTypes = 1;
- openPTypeList [0] = kFileType;
- } /*InitFileM*/
-
- /*----------*/
- void InitFileMB (void)
- {
- numOpenTypes = 1;
- openBTypeList [0] = mFileType;
- } /*InitFileM*/
-
-
- /*----------*/
- static void DoNew (void)
- {
- /*OpenWindows ("\p", 0, 0);*/
- InitAppData (); /* apparently does nothing */
-
- } /*DoNew*/
-
-
- /*----------*/
- static void DoOpenData (void)
- {
- Point dialogOrigin;
- SFReply sfInfo;
-
- SetPt (&dialogOrigin, dialogLeft, dialogTop);
- SFGetFile (dialogOrigin, "\p", nil, numOpenTypes, openDTypeList, nil, &sfInfo);
- if (sfInfo.good) {
- OpenDoc (sfInfo.fName, sfInfo.vRefNum); /* this */
- }
- } /*DoOpen*/
-
-
- /*----------*/
- static void DoOpenProg (void)
- {
- Point dialogOrigin;
- SFReply sfInfo;
-
- SetPt (&dialogOrigin, dialogLeft, dialogTop);
- SFGetFile (dialogOrigin, "\p", nil, numOpenTypes, openPTypeList, nil, &sfInfo);
- if (sfInfo.good) {
- OpenDoc (sfInfo.fName, sfInfo.vRefNum);
- }
- } /*DoOpen*/
-
- /*----------*/
- void OpenApp (void)
- {
- DoNew ();
- } /*OpenApp*/
-
-
-
- /*----------*/
- static void DoSaveProg (void)
- {
- SFReply sfInfo;
- short pRefNum;
- short selector = 1; /* 1 for program, 0 for data */
- StringHandle prompt;
- Str255 promptStr;
- Str255 suggestion;
-
- prompt = GetString (SaveProgramAsPromptID);
-
- /* prompt becomes string in dialog box above field for program name */
-
- if (prompt != nil) {
- BlockMove (&(**prompt), promptStr, GetHandleSize ((Handle) prompt));
- } else {
- promptStr [0] = 0;
- }
- BlockMove (&(**cur->pFilename), suggestion, GetHandleSize ((Handle) cur->pFilename));
-
- if (CreateFile (&sfInfo, promptStr, suggestion, kSignature, kFileType)) {
- CloseAppFile (cur->pFileNum);
- if (OpenAppFile (sfInfo.vRefNum, sfInfo.fName, &pRefNum)) {
- /*SetWTitle (curWindow, sfInfo.fName);*/
- cur->pFileNum = pRefNum;
- cur->volNum = sfInfo.vRefNum;
- SetString (cur->pFilename, sfInfo.fName);
- WriteAppFile (selector,cur->pFileNum); /* in C14CalculatorData.c, does FlushVol() */
- cur->pDirty = false; /* doesn't Close() */
- } else { /*should never happen*/
- /*SetWTitle (curWindow, "\p???");*/
- cur->pFileNum = 0;
- cur->volNum = 0;
- }
- }
- } /*DoSaveProg*/
-
-
- /*----------*/
- static void DoSaveData (void)
- {
- SFReply sfInfo;
- short qRefNum;
- short selector = 0; /* 0 for data, 1 for program */
- StringHandle prompt;
- Str255 promptStr;
- Str255 suggestion;
-
- prompt = GetString (SaveDataAsPromptID);
- if (prompt != nil) {
- BlockMove (&(**prompt), promptStr, GetHandleSize ((Handle) prompt));
- } else {
- promptStr [0] = 0;
- }
- BlockMove (&(**cur->qFilename), suggestion, GetHandleSize ((Handle) cur->qFilename));
-
- /* cur->qFilename established in WindowInit() in calc_inits.c */
- /* suggestion is default filename to be displayed in input box */
-
- if (CreateFile (&sfInfo, promptStr, suggestion, kSignature, lFileType)) {
- CloseAppFile (cur->qFileNum);
- if (OpenAppFile (sfInfo.vRefNum, sfInfo.fName, &qRefNum)) {
- /*SetWTitle (curWindow, sfInfo.fName);*/
- cur->qFileNum = qRefNum;
- cur->volNum = sfInfo.vRefNum;
- SetString (cur->qFilename, sfInfo.fName);
- WriteAppFile (selector,cur->qFileNum);
- cur->qDirty = false;
- } else { /*should never happen*/
- /*SetWTitle (curWindow, "\p???");*/
- cur->qFileNum = 0;
- cur->volNum = 0;
- }
- }
- } /*DoSaveData*/
-
-
- /*----------*/
- void OpenDoc (Str255 fileName,
- short vRefNum)
- {
- /* This *should* be defined in an Apple interface file: */
- #define StationeryFlag 0x0800
-
- Boolean isStationery;
- FInfo finderInfo;
- short fRefNum;
-
- isStationery = false;
- if (GetFInfo (fileName, vRefNum, &finderInfo) == noErr) {
- if ((finderInfo.fdFlags & StationeryFlag) != 0) {
- isStationery = true;
- }
- }
- if (OpenAppFile (vRefNum, fileName, &fRefNum)) {
- if (isStationery) {
- /*OpenWindows ("\p", 0, 0);*/
- ReadAppFile (fRefNum);
- CloseAppFile (fRefNum);
- } else {
- /*OpenWindows (fileName, vRefNum, fRefNum);*/
- ReadAppFile (fRefNum); /* C14CalculatorData.c */
- }
- }
- } /*OpenDoc*/
-
- void DoWizOpenProg (void)
- {
- DoOpenProg();
- }
-
- void DoWizOpenData (void)
- {
- DoOpenData();
- }
-
-
-
-
-
- void DoWizNew (void)
- {
- DoNew();
- }
-
- void DoWizClose (void)
- {
- DoSaveProg();
- FSClose(cur->pFileNum);
- gLoadProgEnabled = TRUE;
- DisableItem(GetMHandle(FILE_MENU_ID), 5);
- EnableItem(GetMHandle(FILE_MENU_ID), 6);
- }
-
- void DoWizSaveData(void)
- {
- DoSaveData();
- }
-
- void DoWizSaveProg(void)
- {
- DoSaveProg();
- }